(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

rev(ls) → r1(ls, empty)
r1(empty, a) → a
r1(cons(x, k), a) → r1(k, cons(x, a))

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

rev(ls) → r1(ls, empty) [1]
r1(empty, a) → a [1]
r1(cons(x, k), a) → r1(k, cons(x, a)) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

rev(ls) → r1(ls, empty) [1]
r1(empty, a) → a [1]
r1(cons(x, k), a) → r1(k, cons(x, a)) [1]

The TRS has the following type information:
rev :: empty:cons → empty:cons
r1 :: empty:cons → empty:cons → empty:cons
empty :: empty:cons
cons :: a → empty:cons → empty:cons

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants:

const

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

rev(ls) → r1(ls, empty) [1]
r1(empty, a) → a [1]
r1(cons(x, k), a) → r1(k, cons(x, a)) [1]

The TRS has the following type information:
rev :: empty:cons → empty:cons
r1 :: empty:cons → empty:cons → empty:cons
empty :: empty:cons
cons :: a → empty:cons → empty:cons
const :: a

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

empty => 0
const => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

r1(z, z') -{ 1 }→ a :|: z' = a, a >= 0, z = 0
r1(z, z') -{ 1 }→ r1(k, 1 + x + a) :|: z' = a, a >= 0, x >= 0, k >= 0, z = 1 + x + k
rev(z) -{ 1 }→ r1(ls, 0) :|: ls >= 0, z = ls

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V2),0,[rev(V, Out)],[V >= 0]).
eq(start(V, V2),0,[r1(V, V2, Out)],[V >= 0,V2 >= 0]).
eq(rev(V, Out),1,[r1(V1, 0, Ret)],[Out = Ret,V1 >= 0,V = V1]).
eq(r1(V, V2, Out),1,[],[Out = V3,V2 = V3,V3 >= 0,V = 0]).
eq(r1(V, V2, Out),1,[r1(V4, 1 + V5 + V6, Ret1)],[Out = Ret1,V2 = V6,V6 >= 0,V5 >= 0,V4 >= 0,V = 1 + V4 + V5]).
input_output_vars(rev(V,Out),[V],[Out]).
input_output_vars(r1(V,V2,Out),[V,V2],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [r1/3]
1. non_recursive : [rev/2]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into r1/3
1. SCC is completely evaluated into other SCCs
2. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations r1/3
* CE 5 is refined into CE [6]
* CE 4 is refined into CE [7]


### Cost equations --> "Loop" of r1/3
* CEs [7] --> Loop 4
* CEs [6] --> Loop 5

### Ranking functions of CR r1(V,V2,Out)
* RF of phase [5]: [V]

#### Partial ranking functions of CR r1(V,V2,Out)
* Partial RF of phase [5]:
- RF of loop [5:1]:
V


### Specialization of cost equations start/2
* CE 2 is refined into CE [8,9]
* CE 3 is refined into CE [10,11]


### Cost equations --> "Loop" of start/2
* CEs [9,11] --> Loop 6
* CEs [8,10] --> Loop 7

### Ranking functions of CR start(V,V2)

#### Partial ranking functions of CR start(V,V2)


Computing Bounds
=====================================

#### Cost of chains of r1(V,V2,Out):
* Chain [[5],4]: 1*it(5)+1
Such that:it(5) =< -V2+Out

with precondition: [V+V2=Out,V>=1,V2>=0]

* Chain [4]: 1
with precondition: [V=0,V2=Out,V2>=0]


#### Cost of chains of start(V,V2):
* Chain [7]: 2
with precondition: [V=0]

* Chain [6]: 2*s(1)+2
Such that:aux(1) =< V
s(1) =< aux(1)

with precondition: [V>=1]


Closed-form bounds of start(V,V2):
-------------------------------------
* Chain [7] with precondition: [V=0]
- Upper bound: 2
- Complexity: constant
* Chain [6] with precondition: [V>=1]
- Upper bound: 2*V+2
- Complexity: n

### Maximum cost of start(V,V2): 2*V+2
Asymptotic class: n
* Total analysis performed in 61 ms.

(10) BOUNDS(1, n^1)